<!DOCTYPE html>
<!-- saved from url=(0056)https://www.cnblogs.com/huliangwen/articles/5005756.html -->
<html lang="zh-cn" style="--olcb-folder-code-block-max-height:80vh;"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="referrer" content="origin-when-cross-origin">
    <meta name="description" content="1 简介 1.1 功能 SQLite是一款开源的、嵌入式关系型数据库。 1.2 第一个程序：封装查询 1) 源文件 如下是使用 sqlite3 C API的源文件，该程序主要功能是创建一个数据库文件，">
    <meta property="og:description" content="1 简介 1.1 功能 SQLite是一款开源的、嵌入式关系型数据库。 1.2 第一个程序：封装查询 1) 源文件 如下是使用 sqlite3 C API的源文件，该程序主要功能是创建一个数据库文件，">
    <meta http-equiv="Cache-Control" content="no-transform">
    <meta http-equiv="Cache-Control" content="no-siteapp">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>SQLite3 API总结 - xiuneng - 博客园</title>
    <link id="favicon" rel="shortcut icon" href="https://common.cnblogs.com/favicon.svg" type="image/svg+xml">
    
    <style>#home :not(.cnblogs_code):not(.cnblogs_Highlighter)>pre:not([highlighted]):not([class*="brush:"]) code:not(.hljs), :not(.cnblogs_code):not(.cnblogs_Highlighter)>pre:not([highlighted]):not([class*="brush:"]) code:not(.hljs) {background: rgb(245, 245, 245);
        padding: 12px;
        border: 1px solid rgb(204, 204, 204);
        border-radius: 3px;
        border-color: transparent;
        color: rgb(68, 68, 68);
        font-family: "Courier New", sans-serif;
        font-size: 12px</style><link rel="stylesheet" href="./SQLite3 API总结_files/blog-common.min.css">
    <link id="MainCss" rel="stylesheet" href="./SQLite3 API总结_files/bundle-codinglife.min.css">
        <link id="highlighter-theme-cnblogs" type="text/css" rel="stylesheet" href="./SQLite3 API总结_files/cnblogs.css">
    
    <link id="mobile-style" media="only screen and (max-width: 767px)" type="text/css" rel="stylesheet" href="./SQLite3 API总结_files/bundle-codinglife-mobile.min.css">
    
    
    
    <link type="application/rss+xml" rel="alternate" href="https://www.cnblogs.com/huliangwen/rss">
    <link type="application/rsd+xml" rel="EditURI" href="https://www.cnblogs.com/huliangwen/rsd.xml">
    <link type="application/wlwmanifest+xml" rel="wlwmanifest" href="https://www.cnblogs.com/huliangwen/wlwmanifest.xml">
    <script type="text/javascript" async="" src="./SQLite3 API总结_files/analytics.js"></script><script type="text/javascript" src="./SQLite3 API总结_files/encoder.js"></script><script>
        var currentBlogId = 173795;
        var currentBlogApp = 'huliangwen';
        var isLogined = false;
        var isBlogOwner = false;
        var skinName = 'CodingLife';
        var visitorUserId = '';
        var hasCustomScript = false;
        try {
            if (hasCustomScript && document.referrer && document.referrer.indexOf('baidu.com') >= 0) {
                Object.defineProperty(document, 'referrer', { value: '' });
                Object.defineProperty(Document.prototype, 'referrer', { get: function(){ return ''; } });
            }
        } catch(error) { }
        window.cb_enable_mathjax = false;
        window.mathEngine = 0;
        window.codeHighlightEngine = 1;
        window.enableCodeLineNumber = false;
        window.codeHighlightTheme = 'cnblogs';
        window.darkModeCodeHighlightTheme = 'vs2015';
        window.isDarkCodeHighlightTheme = false;
        window.isDarkModeCodeHighlightThemeDark = true;
        window.isDisableCodeHighlighter = false;
        window.enableCodeThemeTypeFollowSystem = false;
    </script>
        <script>
            var currentPostDateAdded = '2015-11-29 22:04';
        </script>
    <script src="./SQLite3 API总结_files/jquery-2.2.0.min.js"></script>
    <script src="./SQLite3 API总结_files/blog-common.min.js"></script><style>.medium-zoom-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  opacity: 0;
  transition: opacity 300ms;
  will-change: opacity;
}

.medium-zoom--opened .medium-zoom-overlay {
  cursor: pointer;
  cursor: zoom-out;
  opacity: 1;
}

.medium-zoom-image {
  cursor: pointer;
  cursor: zoom-in;
  /*
    The `transition` is marked as "!important" for the animation to happen
    even though it's overriden by another inline `transition` style attribute.

    This is problematic with frameworks that generate inline styles on their
    images (e.g. Gatsby).

    See https://github.com/francoischalifour/medium-zoom/issues/110
   */
  transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) !important;
}

.medium-zoom-image--hidden {
  visibility: hidden;
}

.medium-zoom-image--opened {
  position: relative;
  cursor: pointer;
  cursor: zoom-out;
  will-change: transform;
}
</style><script id="hljs-script" src="./SQLite3 API总结_files/highlight.min.js" type="text/javascript" async=""></script>
    
</head>
<body class="skin-codinglife has-navbar">
<a name="top"></a>
<div id="top_nav" class="navbar forpc">
    <nav id="nav_main" class="navbar-main">
        <ul id="nav_left" class="navbar-list navbar-left">
            <li class="navbar-branding">
                <a href="https://www.cnblogs.com/" title="开发者的网上家园" role="banner">
                    <img src="./SQLite3 API总结_files/logo.svg" alt="博客园Logo">
                </a>
            </li>
            <li>
                <a href="https://www.cnblogs.com/" onclick="countClicks(&#39;skin-navbar-sitehome&#39;)">首页</a>
            </li>
            <li>
                <a href="https://news.cnblogs.com/" onclick="countClicks(&#39;nav&#39;, &#39;skin-navbar-news&#39;)">新闻</a>
            </li>
            <li>
                <a href="https://q.cnblogs.com/" onclick="countClicks(&#39;nav&#39;, &#39;skin-navbar-q&#39;)">博问</a>
            </li>
            <li>
                <a id="nav_brandzone" href="https://brands.cnblogs.com/" onclick="countClicks(&#39;nav&#39;, &#39;skin-navbar-brands&#39;)">专区</a>
            </li>
            <li>
                <a href="https://ing.cnblogs.com/" onclick="countClicks(&#39;nav&#39;, &#39;skin-navbar-ing&#39;)">闪存</a>
            </li>
            <li>
                <a href="https://edu.cnblogs.com/" onclick="countClicks(&#39;nav&#39;, &#39;skin-navbar-edu&#39;)">班级</a>
            </li>
        </ul>
        <ul id="nav_right" class="navbar-list navbar-right">
            <li>
                <form id="zzk_search" class="navbar-search" action="https://zzk.cnblogs.com/s" method="get" role="search">
                    <input name="w" id="zzk_search_input" placeholder="代码改变世界" type="search" tabindex="3">
                    <button type="submit" id="zzk_search_button">
                        <img src="./SQLite3 API总结_files/search.svg" alt="搜索">
                    </button>
                </form>
            </li>
            <li id="navbar_login_status" class="navbar-list">
                <a class="navbar-user-info navbar-blog" href="https://i.cnblogs.com/EditPosts.aspx?opt=1" alt="写随笔" title="写随笔" style="display: none;">
                    <img id="new_post_icon" class="navbar-icon" src="./SQLite3 API总结_files/newpost.svg" alt="写随笔">
                </a>
                <a id="navblog-myblog-icon" class="navbar-user-info navbar-blog" href="https://passport.cnblogs.com/GetBlogApplyStatus.aspx" alt="我的博客" title="我的博客" style="display: none;">
                    <img id="myblog_icon" class="navbar-icon" src="./SQLite3 API总结_files/myblog.svg" alt="我的博客">
                </a>
                <a class="navbar-user-info navbar-message navbar-icon-wrapper" href="https://msg.cnblogs.com/" alt="短消息" title="短消息" style="display: none;">
                    <img id="msg_icon" class="navbar-icon" src="./SQLite3 API总结_files/message.svg" alt="短消息">
                    <span id="msg_count" style="display: none"></span>
                </a>
                <a id="navbar_lite_mode_indicator" data-current-page="blog" style="display: none" href="javascript:void(0)" alt="简洁模式" title="简洁模式启用，您在访问他人博客时会使用简洁款皮肤展示">
                    <img class="navbar-icon" src="./SQLite3 API总结_files/lite-mode-on.svg" alt="简洁模式">
                </a>
                <div id="user_info" class="navbar-user-info dropdown" style="display: none;">
                    <a class="dropdown-button" href="https://home.cnblogs.com/">
                        <img id="user_icon" class="navbar-avatar" src="./SQLite3 API总结_files/avatar-default.svg" alt="用户头像">
                    </a>
                    <div class="dropdown-menu">
                        <a id="navblog-myblog-text" href="https://passport.cnblogs.com/GetBlogApplyStatus.aspx">我的博客</a>
                        <a href="https://home.cnblogs.com/">我的园子</a>
                        <a href="https://account.cnblogs.com/settings/account">账号设置</a>
                        <a href="javascript:void(0)" id="navbar_lite_mode_toggle" title="简洁模式会使用简洁款皮肤显示所有博客">
    简洁模式 <img id="navbar_lite_mode_on" src="./SQLite3 API总结_files/lite-mode-check.svg" class="hide"><span id="navbar_lite_mode_spinner" class="hide">...</span>
</a>
                        <a href="javascript:void(0)" onclick="account.logout();">退出登录</a>
                    </div>
                </div>
                <a class="navbar-anonymous" href="https://account.cnblogs.com/signup" style="display: inline;">注册</a>
                <a class="navbar-anonymous" href="javascript:void(0);" onclick="account.login()" style="display: inline;">登录</a>
            </li>
        </ul>
    </nav>
</div>



<!--done-->
<div id="home">
<div id="header">
	<div id="blogTitle">
        <a id="lnkBlogLogo" href="https://www.cnblogs.com/huliangwen/"><img id="blogLogo" src="./SQLite3 API总结_files/logo.gif" alt="返回主页"></a>		
		
<!--done-->
<h1><a id="Header1_HeaderTitle" class="headermaintitle HeaderMainTitle" href="https://www.cnblogs.com/huliangwen/">修能</a>
</h1>
<h2></h2>




		
	</div><!--end: blogTitle 博客的标题和副标题 -->
	<div id="navigator">
		
<ul id="navList">
<li><a id="blog_nav_sitehome" class="menu" href="https://www.cnblogs.com/">
博客园</a>
</li>
<li>
<a id="blog_nav_myhome" class="menu" href="https://www.cnblogs.com/huliangwen/">
首页</a>
</li>
<li>

<a id="blog_nav_newpost" class="menu" href="https://i.cnblogs.com/EditPosts.aspx?opt=1">
新随笔</a>
</li>
<li>
<a id="blog_nav_contact" class="menu" href="https://msg.cnblogs.com/send/xiuneng">
联系</a></li>
<li>
<a id="blog_nav_rss" class="menu" href="javascript:void(0)" data-rss="https://www.cnblogs.com/huliangwen/rss/">
订阅</a>
<!--<partial name="./Shared/_XmlLink.cshtml" model="Model" /></li>--></li>
<li>
<a id="blog_nav_admin" class="menu" href="https://i.cnblogs.com/">
管理</a>
</li>
</ul>


		<div class="blogStats">
			<span id="stats_post_count">随笔 - 60&nbsp; </span>
<span id="stats_article_count">文章 - 20&nbsp; </span>
<span id="stats-comment_count">评论 - 7&nbsp; </span>
<span id="stats-total-view-count">阅读 - 
<span title="总阅读数: 207986">
20万</span></span>

		</div><!--end: blogStats -->
	</div><!--end: navigator 博客导航栏 -->
</div><!--end: header 头部 -->
<div id="main">
	<div id="mainContent">
	<div class="forFlow">
		<div id="post_detail">
    <!--done-->
    <div id="topics">
        <div class="post">
            <h1 class="postTitle">
                
<a id="cb_post_title_url" class="postTitle2 vertical-middle" href="https://www.cnblogs.com/huliangwen/articles/5005756.html">
    <span role="heading" aria-level="2">SQLite3 API总结</span>
    
</a><button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button>

            </h1>
            <div class="clear"></div>
            <div class="postBody">
                <div id="cnblogs_post_body" class="blogpost-body blogpost-body-html">
<style type="text/css" isprelink="true">@import url("http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css");</style><style type="text/css">@import url("/css/cuteeditor.css");</style>
<style type="text/css" isprelink="true">@import url("http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css");</style><style type="text/css">@import url("/css/cuteeditor.css");</style>
<style type="text/css" isprelink="true">@import url("http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css");</style><style type="text/css">@import url("/css/cuteeditor.css");</style>
<style type="text/css" isprelink="true">@import url("http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css");</style><style type="text/css">@import url("/css/cuteeditor.css");</style>
<style type="text/css" isprelink="true">@import url("http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css");</style><style type="text/css">@import url("/css/cuteeditor.css");</style>
<p style="text-align: justify">
</p>
<h1>1 简介 <button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h1>
<h2 style="text-align: justify">1.1 功能 <button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h2>
<p style="margin-left: 21pt">SQLite是一款开源的、嵌入式关系型数据库。 </p>
<h2 style="text-align: justify">1.2 第一个程序：封装查询 <button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h2>
<p style="text-align: justify"><span style="font-size: 10pt"><strong><span style="font-family: 宋体">1) 源文件</span><span style="font-family: Times New Roman"> </span></strong></span></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; 如下是使用 sqlite3 C API的源文件，该程序主要功能是创建一个数据库文件，接着创建一个表，然后插入一条数据，最后查询表输出表内容。&nbsp;</p>
<div class="cnblogs_code"><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./SQLite3 API总结_files/copycode.gif" alt="复制代码"></a></span></div>
<div><span style="color: rgba(0, 128, 128, 1)">&nbsp;1</span>&nbsp;<span style="color: rgba(0, 0, 255, 1)">int</span>&nbsp;main()&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">&nbsp;2</span>&nbsp;{&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">&nbsp;3</span>&nbsp;&nbsp;&nbsp;&nbsp; sqlite3&nbsp;*db;&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">&nbsp;4</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgba(0, 0, 255, 1)">char</span>&nbsp;*zErrMsg&nbsp;=&nbsp;<span style="color: rgba(128, 0, 128, 1)">0</span>;&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">&nbsp;5</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgba(0, 0, 255, 1)">int</span>&nbsp;rc;&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">&nbsp;6</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgba(0, 0, 255, 1)">char</span>&nbsp;*baseName&nbsp;=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">base</span><span style="color: rgba(128, 0, 0, 1)">"</span>;&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">&nbsp;7</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgba(0, 0, 255, 1)">char</span>&nbsp;*createSQL&nbsp;=&nbsp;<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">create&nbsp;table&nbsp;episodes(id&nbsp;integer&nbsp;primary&nbsp;key,&nbsp;season&nbsp;int,&nbsp;name&nbsp;text);</span><span style="color: rgba(128, 0, 0, 1)">"</span>;&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">&nbsp;8</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgba(0, 0, 255, 1)">char</span>&nbsp;*insertSQL&nbsp;=&nbsp;<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">insert&nbsp;into&nbsp;episodes(id,name)&nbsp;values(1,\"hello\");</span><span style="color: rgba(128, 0, 0, 1)">"</span>;&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">&nbsp;9</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgba(0, 0, 255, 1)">char</span>&nbsp;*selectSQL&nbsp;=&nbsp;<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">select&nbsp;*&nbsp;from&nbsp;episodes;</span><span style="color: rgba(128, 0, 0, 1)">"</span>;&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">10</span>&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">11</span>&nbsp;&nbsp;&nbsp;&nbsp; rc&nbsp;=&nbsp;sqlite3_open(baseName,&nbsp;&amp;db);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">创建数据库&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span><span style="color: rgba(0, 128, 128, 1)">12</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgba(0, 128, 0, 1)"></span>rc&nbsp;=&nbsp;sqlite3_exec(db,&nbsp;createSQL,&nbsp;NULL,&nbsp;NULL,&nbsp;&amp;zErrMsg);&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">创建表&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span><span style="color: rgba(0, 128, 128, 1)">13</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgba(0, 128, 0, 1)"></span>rc&nbsp;=&nbsp;sqlite3_exec(db,&nbsp;insertSQL,&nbsp;NULL,&nbsp;NULL,&nbsp;&amp;zErrMsg);&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">插入数据&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span><span style="color: rgba(0, 128, 128, 1)">14</span>&nbsp;<span style="color: rgba(0, 128, 0, 1)"></span><br>
<span style="color: rgba(0, 128, 128, 1)">15</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgba(0, 0, 255, 1)">char</span>&nbsp;**result;&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">16</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgba(0, 0, 255, 1)">int</span>&nbsp;nrow,&nbsp;ncolumn;&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">17</span>&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">18</span>&nbsp;&nbsp;&nbsp;&nbsp; rc&nbsp;=&nbsp;sqlite3_get_table(db,&nbsp;selectSQL,&amp;result,&amp;nrow,&amp;ncolumn,&amp;zErrMsg);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">查询表格&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span><span style="color: rgba(0, 128, 128, 1)">19</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgba(0, 128, 0, 1)"></span><span style="color: rgba(0, 0, 255, 1)">int</span>&nbsp;i,&nbsp;j;&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">20</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgba(0, 0, 255, 1)">for</span>(i=<span style="color: rgba(128, 0, 128, 1)">0</span>;&nbsp;i&lt;=nrow;&nbsp;i++)&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">21</span>&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">22</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgba(0, 0, 255, 1)">for</span>(j=<span style="color: rgba(128, 0, 128, 1)">0</span>;&nbsp;j&lt;ncolumn;&nbsp;j++)&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">23</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">%s\t</span><span style="color: rgba(128, 0, 0, 1)">"</span>,result[i*ncolumn+j]);&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">24</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">\n</span><span style="color: rgba(128, 0, 0, 1)">"</span>);&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">25</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">26</span>&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">27</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sqlite3_close(db);&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">28</span>&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">29</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 0, 255, 1)">return</span>&nbsp;<span style="color: rgba(128, 0, 128, 1)">0</span>；&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">30</span>&nbsp;}</div>
<div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./SQLite3 API总结_files/copycode.gif" alt="复制代码"></a></span></div></div>
<p>&nbsp;</p>
<p style="text-align: justify"><span style="font-size: 10pt"><strong><span style="font-family: 宋体">2) 编译命令</span><span style="font-family: Times New Roman"> </span></strong></span></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; 在Linux平台上，要编译sqlite3源文件，需要将sqlite3.c文件拷贝到源程序文件所在的目录，然后按如下进行编译。 </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;<strong><span style="color: rgba(255, 0, 0, 1)">gcc sqlite3.c firstSqlite.c -lpthread –ldl</span> </strong></p>
<h2 style="text-align: justify">1.3 第二个程序：准备查询 <button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h2>
<p style="text-align: justify"><span style="font-size: 10pt"><strong><span style="font-family: 宋体">1) 查询</span><span style="font-family: Times New Roman"> </span></strong></span></p>
<p style="text-align: justify"><span style="font-size: 10pt"><strong><span style="font-family: Times New Roman"></span></strong></span></p>
<strong>
<div class="cnblogs_code"><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./SQLite3 API总结_files/copycode.gif" alt="复制代码"></a></span></div>
<div><span style="color: rgba(0, 128, 128, 1)">&nbsp;1</span>&nbsp;<span style="color: rgba(0, 0, 255, 1)">void</span>&nbsp;test_prepare_select()&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">&nbsp;2</span>&nbsp;{&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">&nbsp;3</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgba(0, 0, 255, 1)">int</span>&nbsp;rc,&nbsp;i,ncols;&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">&nbsp;4</span>&nbsp;&nbsp;&nbsp;&nbsp; sqlite3&nbsp;*db;&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">&nbsp;5</span>&nbsp;&nbsp;&nbsp;&nbsp; sqlite3_stmt&nbsp;*stmt;&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">&nbsp;6</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgba(0, 0, 255, 1)">char</span>&nbsp;*sql=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">select&nbsp;*&nbsp;from&nbsp;episodes;</span><span style="color: rgba(128, 0, 0, 1)">"</span>;;&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">&nbsp;7</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgba(0, 0, 255, 1)">const</span>&nbsp;<span style="color: rgba(0, 0, 255, 1)">char</span>&nbsp;*tail;&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">&nbsp;8</span>&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">&nbsp;9</span>&nbsp;&nbsp;&nbsp;&nbsp; rc&nbsp;=&nbsp;sqlite3_open(<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">base</span><span style="color: rgba(128, 0, 0, 1)">"</span>,&amp;db);&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">fprintf(stderr,&nbsp;"can't&nbsp;open&nbsp;datebase:%s\n",sqlite3_errmsg(db));&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span><span style="color: rgba(0, 128, 128, 1)">10</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgba(0, 128, 0, 1)"></span>rc&nbsp;=&nbsp;sqlite3_prepare_v2(db,sql,-<span style="color: rgba(128, 0, 128, 1)">1</span>,&amp;stmt,&amp;tail);&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">11</span>&nbsp;&nbsp;&nbsp;&nbsp; rc&nbsp;=&nbsp;sqlite3_step(stmt);&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">12</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgba(0, 0, 255, 1)">while</span>(rc&nbsp;!=&nbsp;SQLITE_DONE)&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">13</span>&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">14</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ncols&nbsp;=&nbsp;sqlite3_column_count(stmt);&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">15</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgba(0, 0, 255, 1)">for</span>(i=<span style="color: rgba(128, 0, 128, 1)">0</span>;&nbsp;i&lt;ncols;&nbsp;i++)&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">16</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">17</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">'%s'</span><span style="color: rgba(128, 0, 0, 1)">"</span>,sqlite3_column_text(stmt,i));&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">18</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">19</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">\n</span><span style="color: rgba(128, 0, 0, 1)">"</span>);&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">20</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rc&nbsp;=&nbsp;sqlite3_step(stmt);&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">21</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">22</span>&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">23</span>&nbsp;&nbsp;&nbsp;&nbsp; sqlite3_finalize(stmt);&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">24</span>&nbsp;&nbsp;&nbsp;&nbsp; sqlite3_close(db);&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">25</span>&nbsp;}&nbsp;</div>
<div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./SQLite3 API总结_files/copycode.gif" alt="复制代码"></a></span></div></div>
</strong>
<p style="text-align: justify"><strong></strong>&nbsp;</p>
<p style="text-align: justify"><span style="font-size: 10pt"><strong><span style="font-family: 宋体">2) 绑定</span><span style="font-family: Times New Roman"> </span></strong></span></p>
<div class="cnblogs_code"><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./SQLite3 API总结_files/copycode.gif" alt="复制代码"></a></span></div>
<div><span style="color: rgba(0, 128, 128, 1)">&nbsp;1</span>&nbsp;<span style="color: rgba(0, 0, 255, 1)">void</span>&nbsp;test_prepare_bind()&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">&nbsp;2</span>&nbsp;{&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">&nbsp;3</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgba(0, 0, 255, 1)">int</span>&nbsp;rc,&nbsp;i,ncols;&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">&nbsp;4</span>&nbsp;&nbsp;&nbsp;&nbsp; sqlite3&nbsp;*db;&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">&nbsp;5</span>&nbsp;&nbsp;&nbsp;&nbsp; sqlite3_stmt&nbsp;*stmt;&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">&nbsp;6</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgba(0, 0, 255, 1)">char</span>&nbsp;*sql&nbsp;=&nbsp;<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">insert&nbsp;into&nbsp;episodes&nbsp;(id,name)&nbsp;values&nbsp;(?,&nbsp;?);</span><span style="color: rgba(128, 0, 0, 1)">"</span>;&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">&nbsp;7</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgba(0, 0, 255, 1)">const</span>&nbsp;<span style="color: rgba(0, 0, 255, 1)">char</span>&nbsp;*tail;&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">&nbsp;8</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgba(0, 0, 255, 1)">char</span>&nbsp;*createSQL&nbsp;=&nbsp;<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">create&nbsp;table&nbsp;episodes(id&nbsp;integer&nbsp;primary&nbsp;key,&nbsp;season&nbsp;int,&nbsp;name&nbsp;text);</span><span style="color: rgba(128, 0, 0, 1)">"</span>;&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">&nbsp;9</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgba(0, 0, 255, 1)">char</span>&nbsp;*zErrMsg&nbsp;=&nbsp;<span style="color: rgba(128, 0, 128, 1)">0</span>;&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">10</span>&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">11</span>&nbsp;&nbsp;&nbsp;&nbsp; sqlite3_open(<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">base</span><span style="color: rgba(128, 0, 0, 1)">"</span>,&amp;db);&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">12</span>&nbsp;&nbsp;&nbsp;&nbsp; sqlite3_exec(db,&nbsp;createSQL,&nbsp;NULL,&nbsp;NULL,&nbsp;&amp;zErrMsg);&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">13</span>&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">14</span>&nbsp;&nbsp;&nbsp;&nbsp; sqlite3_prepare_v2(db,sql,-<span style="color: rgba(128, 0, 128, 1)">1</span>,&amp;stmt,&amp;tail);&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">15</span>&nbsp;&nbsp;&nbsp;&nbsp; sqlite3_bind_int(stmt,&nbsp;<span style="color: rgba(128, 0, 128, 1)">1</span>,&nbsp;<span style="color: rgba(128, 0, 128, 1)">1</span>);&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">16</span>&nbsp;&nbsp;&nbsp;&nbsp; sqlite3_bind_text(stmt,<span style="color: rgba(128, 0, 128, 1)">2</span>,<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">hello</span><span style="color: rgba(128, 0, 0, 1)">"</span>,&nbsp;strlen(<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">hello</span><span style="color: rgba(128, 0, 0, 1)">"</span>),&nbsp;SQLITE_TRANSIENT);&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">17</span>&nbsp;&nbsp;&nbsp;&nbsp; sqlite3_step(stmt);&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">18</span>&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">19</span>&nbsp;&nbsp;&nbsp;&nbsp; sqlite3_finalize(stmt);&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">20</span>&nbsp;&nbsp;&nbsp;&nbsp; sqlite3_close(db);&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">21</span>&nbsp;}&nbsp;</div>
<div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./SQLite3 API总结_files/copycode.gif" alt="复制代码"></a></span></div></div>
<p>&nbsp;</p>
<p style="text-align: justify">
</p>
<h1>2 SQLite3设计与概念 <button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h1>
<h2 style="text-align: justify">2.1 API对象模型 <button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h2>
<p style="margin-left: 22pt">SQLite3 C API 的对象模型结构可以由下图表示，即任何一个SQlite3数据库都存储在操作系统文件中——一个数据库对应一个操作系统文件。 </p>
<p style="text-align: center"><img alt="" src="./SQLite3 API总结_files/499013-20151129220332407-1314364629.png" class="medium-zoom-image"> </p>
<h3 style="text-align: justify">2.1.1 连接与语句 <button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h3>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; API中与查询处理有关的两个基本数据结构是连接(sqlite3)和语句(sqlite3_stmt)，API中所有的主要操作都在使用这两个结构。其中连接负责管理语句，即在一个连接中只能存在一个语句，所以在每个连接中都设置一个table Locks的锁，从而保证这种唯一性。 </p>
<ul style="margin-left: 42pt">
    <li>
    <div style="text-align: justify"><span style="font-size: 10pt"><span style="font-family: 宋体">连接：</span><span style="font-family: Times New Roman">sqlite3 </span></span></div>
    <p style="text-align: justify"><span style="font-size: 10pt"><span style="font-family: 宋体">一个连接对象代表到数据库的连接和事务上下文，</span><span style="font-family: Times New Roman">statement</span><span style="font-family: 宋体">来自连接对象；</span><span style="font-family: Times New Roman"> </span></span></p>
    </li>
    <li>
    <div style="text-align: justify"><span style="font-size: 10pt"><span style="font-family: 宋体">语句：</span><span style="font-family: Times New Roman">sqlite3_Stmt </span></span></div>
    <p style="text-align: justify"><span style="font-size: 10pt"><span style="font-family: 宋体">一个</span><span style="font-family: Times New Roman">statement</span><span style="font-family: 宋体">对象代表了一个编译的</span><span style="font-family: Times New Roman">SQL</span><span style="font-family: 宋体">语句。在内部，它使用</span><span style="font-family: Times New Roman">VDBE</span><span style="font-family: 宋体">字节码来表示，</span><span style="font-family: Times New Roman">VDBE</span><span style="font-family: 宋体">字节码是一个会执行</span><span style="font-family: Times New Roman">SQL</span><span style="font-family: 宋体">命令的程序。</span><span style="font-family: Times New Roman">statement</span><span style="font-family: 宋体">包括执行一个命令所需要的一切东西。</span><span style="font-family: Times New Roman"> </span></span></p>
    </li>
</ul>
<p style="text-align: justify">
</p>
<h3>2.1.2 B-tree与Pager <button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h3>
<p>&nbsp;&nbsp;&nbsp;&nbsp; 一个连接对象可以连接到多个数据库对象——一个主数据库和多个附加数据库。每个数据库对象都有一个B-tree和相应的一个pager对象。statement使用它们连接对象的B-tree和pager从数据库中读取数据，向数据库写入数据。并且保证一个数据库只存在一个连接，从而产生一个Database Lock的锁。 </p>
<ul style="margin-left: 42pt">
    <li>
    <div style="text-align: justify"><span style="font-family: Times New Roman; font-size: 10pt">B-tree </span></div>
    <p style="text-align: justify"><span style="font-size: 10pt"><span style="font-family: Times New Roman">B-tree</span><span style="font-family: 宋体">负责与语句进行交互，即读取数据库的</span><span style="font-family: Times New Roman">statement</span><span style="font-family: 宋体">使用游标遍历</span><span style="font-family: Times New Roman">B-tree</span><span style="font-family: 宋体">。然后</span><span style="font-family: Times New Roman">b-tree</span><span style="font-family: 宋体">从</span><span style="font-family: Times New Roman">pager</span><span style="font-family: 宋体">中读取数据。</span><span style="font-family: Times New Roman"> </span></span></p>
    </li>
    <li>
    <div style="text-align: justify"><span style="font-family: Times New Roman; font-size: 10pt">pager </span></div>
    <p style="text-align: justify"><span style="font-size: 10pt"><span style="font-family: 宋体">若一个游标想要访问页面，则</span><span style="font-family: Times New Roman">pager</span><span style="font-family: 宋体">必须从内存加载到磁盘中，然后返回给</span><span style="font-family: Times New Roman">b-tree</span><span style="font-family: 宋体">。并且当游标修改页面时，</span><span style="font-family: Times New Roman">pager</span><span style="font-family: 宋体">必须采取特殊措施保留原始页面，确保在发生事务回滚时可以回到原来的状态。即</span><span style="font-family: Times New Roman">pager</span><span style="font-family: 宋体">负责读写数据库，维护内存缓存或者页面，管理事务。</span><span style="font-family: Times New Roman"> </span></span></p>
    </li>
</ul>
<p style="text-align: justify">
</p>
<h2>2.2 核心API <button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h2>
<p>&nbsp;&nbsp;&nbsp;&nbsp; 核心API是用来执行SQL命令的，它由各种用来执行查询的函数和管理数据库的实用函数组成。执行SQL命令有两种方法：准备查询和封装查询。在API和SQLite内部，准备查询方法最终执行所有命令的方法，它包含准备、执行和完成三个阶段，每个阶段都有一个单独的API函数。而封装查询方法是将准备查询的三个步骤封装成为一个函数调用，并提供了一次执行SQL命令的简便方法。即 </p>
<ul style="margin-left: 42pt">
    <li>
    <div style="text-align: justify"><span style="font-size: 10pt"><span style="font-family: 宋体">准备查询</span><span style="font-family: Times New Roman"> </span></span></div>
    <ul>
        <li>
        <div style="text-align: justify"><span style="font-size: 10pt"><span style="font-family: 宋体">准备：</span><span style="font-family: Times New Roman">sqlite3_prepare(); </span></span></div>
        </li>
        <li>
        <div style="text-align: justify"><span style="font-size: 10pt"><span style="font-family: 宋体">执行：</span><span style="font-family: Times New Roman">sqlite3_step(); </span></span></div>
        </li>
        <li>
        <div style="text-align: justify"><span style="font-size: 10pt"><span style="font-family: 宋体">完成：</span><span style="font-family: Times New Roman">sqlite3_finalize(); </span></span></div>
        </li>
    </ul>
    </li>
    <li>
    <div style="text-align: justify"><span style="font-size: 10pt"><span style="font-family: 宋体">封装查询</span><span style="font-family: Times New Roman"> </span></span></div>
    <ul>
        <li>
        <div style="text-align: justify"><span style="font-family: Times New Roman; font-size: 10pt">sqlite3_exec() </span></div>
        </li>
        <li>
        <div style="text-align: justify"><span style="font-family: Times New Roman; font-size: 10pt">sqlite3_get_table() </span></div>
        </li>
    </ul>
    </li>
</ul>
<p style="text-align: justify">
</p>
<h3>2.2.1 连接数据库 <button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h3>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 因为SQLite数据库其实就是一个操作系统文件，所以连接数据库其实就是打开系统文件。C API 中用于连接或打开一个数据库的函数是sqlite3_open()，基本上就是一个打开文件的系统调用。若打开的数据库文件不存在，则创建一个新的数据库；若存在则将SQLite文件打开。一旦开打一个数据库文件，那么将使用一个不透明的sqlite3连接句柄来表示它，该句柄表示到数据库的一个连接。sqlite扩展中，连接对象抽象了该句柄，并且有时一些对应的API函数实现方法将该句柄作为参数。 </p>
<h3 style="text-align: justify">2.2.2 执行准备查询 <button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h3>
<p style="margin-left: 21pt">正如上述所述，准备查询方法中执行一条SQL命令，需要由三个步骤组成： </p>
<ol style="margin-left: 63pt">
    <li>
    <div style="text-align: justify"><span style="font-size: 10pt"><span style="font-family: 宋体">准备</span><span style="font-family: Times New Roman"> </span></span></div>
    <p style="text-align: justify"><span style="font-size: 10pt"><span style="font-family: 宋体">在</span><span style="font-family: Times New Roman">C API</span><span style="font-family: 宋体">中，这个步骤由</span><span style="font-family: Times New Roman">sqlite3_prepare_ve()</span><span style="font-family: 宋体">函数完成，该函数直接与编译器对话。编译器将命令编译成为</span><span style="font-family: Times New Roman">VDBE</span><span style="font-family: 宋体">字节码，即创建</span><span style="font-family: Times New Roman">sqlit3_stmt</span><span style="font-family: 宋体">句柄。</span><span style="font-family: Times New Roman"> </span></span></p>
    </li>
    <li>
    <div style="text-align: justify"><span style="font-size: 10pt"><span style="font-family: 宋体">执行</span><span style="font-family: Times New Roman"> </span></span></div>
    <p style="text-align: justify"><span style="font-size: 10pt"><span style="font-family: 宋体">执行是一个逐步的过程，</span><span style="font-family: Times New Roman">C API</span><span style="font-family: 宋体">中每一步都由</span><span style="font-family: Times New Roman">sqlite3_step()</span><span style="font-family: 宋体">发起，并使</span><span style="font-family: Times New Roman">VDBE</span><span style="font-family: 宋体">逐步执行字节码，第一次调用</span><span style="font-family: Times New Roman">sqlite3_step()</span><span style="font-family: 宋体">通常需要某种类型的锁，锁的类型根据执行什么样的命令</span><span style="font-family: Times New Roman">(</span><span style="font-family: 宋体">读或写</span><span style="font-family: Times New Roman">)</span><span style="font-family: 宋体">而变化。对于</span><span style="font-family: Times New Roman">select</span><span style="font-family: 宋体">语句，</span><span style="font-family: Times New Roman">sqlite3_step()</span><span style="font-family: 宋体">的每次调用将使语句句柄的游标位置移动到结果集的下一行。对于结果集中的每一行，游标未到达结果集末尾时，将返回</span><span style="font-family: Times New Roman">SQLITE_ROW;</span><span style="font-family: 宋体">繁殖，将返回</span><span style="font-family: Times New Roman">SQLITE_DONE</span><span style="font-family: 宋体">。对于其他</span><span style="font-family: Times New Roman">SQL</span><span style="font-family: 宋体">语句</span><span style="font-family: Times New Roman">(insert</span><span style="font-family: 宋体">、</span><span style="font-family: Times New Roman">update</span><span style="font-family: 宋体">、</span><span style="font-family: Times New Roman">delete</span><span style="font-family: 宋体">等</span><span style="font-family: Times New Roman">)</span><span style="font-family: 宋体">，第一次调用</span><span style="font-family: Times New Roman">sqlite3_step()</span><span style="font-family: 宋体">将促使</span><span style="font-family: Times New Roman">VDBE</span><span style="font-family: 宋体">执行整个命令。</span><span style="font-family: Times New Roman"> </span></span></p>
    </li>
    <li>
    <div style="text-align: justify"><span style="font-size: 10pt"><span style="font-family: 宋体">完成</span><span style="font-family: Times New Roman"> </span></span></div>
    <p style="text-align: justify"><span style="font-size: 10pt"><span style="font-family: Times New Roman">VDBE</span><span style="font-family: 宋体">关闭语句并释放资源。</span><span style="font-family: Times New Roman">C API</span><span style="font-family: 宋体">中，由</span><span style="font-family: Times New Roman">sqlite_finalize()</span><span style="font-family: 宋体">来执行，该函数使得</span><span style="font-family: Times New Roman">VDBE</span><span style="font-family: 宋体">终止程序、释放资源并关闭</span><span style="font-family: Times New Roman">statement</span><span style="font-family: 宋体">句柄。</span><span style="font-family: Times New Roman"> </span></span></p>
    </li>
</ol>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 每一步（准备、执行、完成）对应statement句柄的各自状态（准备状态、执行状态、完成状态）。准备状态以为这所有必需的资源以及分配，statement已准备执行，但是没有启动，没有获得锁，也没有申请获得锁，知道第一次调用sqlite3_step()时才开始获取锁。活动状态从第一次调用sqlite3_step()开始。此时，statement处于执行过程中，并且开始使用某种类型的锁。完成状态意味着开始使用关闭，并且所有相关的资源已被释放。如下图所示： </p>
<p style="text-align: center"><img alt="" src="./SQLite3 API总结_files/499013-20151129220332969-2010563271.png" class="medium-zoom-image"> </p>
<h3 style="text-align: justify">2.2.3 使用参数化SQL <button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h3>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLite3语句可以包含参数，即该参数就是占位符，可能会在编译后为其提供（或"绑定"）值。当sqlite3_prepare_v2()编译带有参数的语句时，它在结果语句句柄中未这些参数分配占位符。然后，期望语句执行前为这些参数提供值，如果参数没有绑定值，执行该语句时SQLite默认使用NULL。 </p>
<p>其中提供了两种方式的绑定：位置绑定和命名绑定； </p>
<ul style="margin-left: 42pt">
    <li>
    <div style="text-align: justify"><span style="font-size: 10pt"><span style="font-family: 宋体">位置绑定</span><span style="font-family: Times New Roman"> </span></span></div>
    <p style="text-align: justify"><span style="font-size: 10pt"><span style="font-family: 宋体">位置绑定是通过问号定义的，第一个问号表示位置</span><span style="font-family: Times New Roman">1</span><span style="font-family: 宋体">，第二个为</span><span style="font-family: Times New Roman">2</span><span style="font-family: 宋体">，依次类推。</span><span style="font-family: Times New Roman"> </span></span></p>
    </li>
    <li>
    <div style="text-align: justify"><span style="font-size: 10pt"><span style="font-family: 宋体">命名绑定</span><span style="font-family: Times New Roman"> </span></span></div>
    <p style="text-align: justify"><span style="font-size: 10pt"><span style="font-family: 宋体">命名绑定使用实际变量名，以冒号作为前缀。</span><span style="font-family: Times New Roman"> </span></span></p>
    </li>
</ul>
<p>下面是参数化查询示例： </p>
<div class="cnblogs_code">
<div><span style="color: rgba(0, 128, 128, 1)">1</span>&nbsp;insert&nbsp;into&nbsp;episodes(id,&nbsp;name)&nbsp;values&nbsp;(?,&nbsp;?);&nbsp;<br>
<span style="color: rgba(0, 128, 128, 1)">2</span>&nbsp;insert&nbsp;into&nbsp;episodes(id,&nbsp;name)&nbsp;values(:id,:name)&nbsp;</div>
</div>
<p>&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;参数绑定的优点是无需重新编译，就可以多次执行相同的语句。只需重置该语句、绑定新值、并重新执行。这时重置函数（sqlite3_reset）就可以发挥作用了：它可以避免SQL编译的开销；并且参数绑定能够使SQlite会处理绑定参数的转义字符。 </p>
<p style="text-align: justify">
</p>
<h1>3 核心C API <button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h1>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLite v3 API包括许多函数。不过，只有8个函数是实际处理连接、处理查询，并断开与数据库连接所必需的。其余函数可以归入专门用于完成特定任务的小组中。可以查询C API参考手册(网址是<a href="http://www.sqlite.org/c3ref/intro.html" rel="noopener">www.sqlite.org/c3ref/intro.html</a>)。 </p>
<p style="text-align: justify">
</p>
<h2>3.1 连接与断开连接: sqlite3_open_v2、sqlite3_close <button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h2>
<p>&nbsp;&nbsp;&nbsp;&nbsp; 在执行SQL命令前，首先要连接数据库。也许将连接数据库成为打开数据库才是更好的表述，因为SQLite数据库包含在单个操作系统文件（一个文件对应一个数据库）中。同理，断开连接可以成为关闭数据库。 </p>
<ul style="margin-left: 42pt">
    <li>
    <div style="text-align: justify"><span style="font-size: 10pt"><span style="font-family: 宋体">打开数据库函数：</span><span style="font-family: Times New Roman"> </span></span></div>
    </li>
</ul>
<div class="cnblogs_code"><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./SQLite3 API总结_files/copycode.gif" alt="复制代码"></a></span></div>
<div><span style="color: rgba(0, 0, 255, 1)">int</span>&nbsp;sqlite3_open_v2(&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 0, 255, 1)">const</span>&nbsp;<span style="color: rgba(0, 0, 255, 1)">char</span>&nbsp;*filename,&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">数据库文件名&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span>&nbsp;&nbsp;&nbsp;&nbsp;sqlite3&nbsp;**ppDb,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">OUT：SQLite数据库句柄&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 0, 255, 1)">int</span>&nbsp;flags,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">标志&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 0, 255, 1)">const</span>&nbsp;<span style="color: rgba(0, 0, 255, 1)">char</span>&nbsp;*zVfs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">要使用的VFS模块的名称&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span>);&nbsp;</div>
<div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./SQLite3 API总结_files/copycode.gif" alt="复制代码"></a></span></div></div>
<p>&nbsp;</p>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 参数filename是操作系统文件，或文本字符串'：memory：'，或空字符串，或空指针。如果使用'：memory：'，sqlite3_open_v2()将在内存中创建数据库，该数据库只存在于连接生成期间。如果文件名是空字符串或null，sqlite3_open_v2()将打开磁盘文件，并在连接关闭时自动删除该文件。
<ul style="margin-left: 42pt">
    <li>
    <div style="text-align: justify"><span style="font-size: 10pt"><span style="font-family: 宋体">关闭数据库</span></span></div>
    </li>
</ul>
<div class="cnblogs_code">
<div><span style="color: rgba(0, 0, 255, 1)">int</span>&nbsp;sqlite3_close(sqlite3*)&nbsp;</div>
</div>
<p style="margin-left: 21pt">&nbsp;&nbsp;&nbsp;&nbsp; 要成功执行sqlite3_clsose(),必须完成与连接关联的所有准备查询。只要有一个查询仍未完成，sqlite3_close()都会返回SQLITE_BUSY并显示错误消息"由于有未完成的语句，所以无法关闭连接"。 </p>
<p style="text-align: justify">
</p>
<h2>3.2 封装查询 <button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h2>
<h3 style="text-align: justify">3.2.1 执行查询：sqlite3_exec <button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h3>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 函数sqlite3_exec()提供一种快速、方便执行SQL命令的方法，对修改数据库的命令(即，不返回任何数据的命令)特别方便。因此，通常也称为便捷函数，一个简单的API调用就能很好地封装很多其他任务。该函数的声明如下： </p>
<div class="cnblogs_code"><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./SQLite3 API总结_files/copycode.gif" alt="复制代码"></a></span></div>
<div><span style="color: rgba(0, 0, 255, 1)">int</span>&nbsp;sqlite3_exec(&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;sqlite3*,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">打开的数据库&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 0, 255, 1)">const</span>&nbsp;<span style="color: rgba(0, 0, 255, 1)">char</span>&nbsp;*sql,&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">要执行的SQL&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span>&nbsp;&nbsp;&nbsp;&nbsp;sqlite_callback,&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">回调函数&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 0, 255, 1)">void</span>&nbsp;*dta,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">回调函数的第一个参数&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 0, 255, 1)">char</span>&nbsp;**errmsg&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">错误信息&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span>);&nbsp;</div>
<div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./SQLite3 API总结_files/copycode.gif" alt="复制代码"></a></span></div></div>
<p>&nbsp;</p>
<p style="margin-left: 21pt">其中SQlite提供的回调函数声明如下：</p>
<div class="cnblogs_code"><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./SQLite3 API总结_files/copycode.gif" alt="复制代码"></a></span></div>
<div>typedef&nbsp;<span style="color: rgba(0, 0, 255, 1)">int</span>&nbsp;(*sqlite3_callback)(&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 0, 255, 1)">void</span>*,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">sqlite3_exe()函数第四个参数提供的数据&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 0, 255, 1)">int</span>,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">行中字段的数目&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 0, 255, 1)">char</span>**,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">代表行中字段名称的字符串数组&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 0, 255, 1)">char</span>**&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">代表字段名称的字符串数组&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span>)&nbsp;</div>
&nbsp;<div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./SQLite3 API总结_files/copycode.gif" alt="复制代码"></a></span></div></div>
<h3 style="text-align: justify">3.2.2 获取查询：sqlite3_get_table <button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h3>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 行数sqlite3_get_table()返回单独函数调用中一个命令的整个结果集，与sqlite3_exec()类似也是封装了准备查收API函数的一些函数，可以一下运行全部的命令。sqlite3_get_table()函数接收SQL语句并返回所有记录，使用堆上声明的内存（使用sqlite3_malloc()）将他们存储在参数result中。必须使用sqlite3_free_table()释放内存，该函数将resultp指针作为唯一的参数。resultp中的一个记录实际上不是记录，而是结果集中列的名称。 </p>
<div class="cnblogs_code"><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./SQLite3 API总结_files/copycode.gif" alt="复制代码"></a></span></div>
<div><span style="color: rgba(0, 0, 255, 1)">int</span>&nbsp;sqlite3_get_table(&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;sqlite3*,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">打开的数据库&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 0, 255, 1)">const</span>&nbsp;<span style="color: rgba(0, 0, 255, 1)">char</span>&nbsp;*sql,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">要执行的SQL&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 0, 255, 1)">char</span>&nbsp;***resultp,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">结果写入该指针执行的&nbsp;&nbsp;&nbsp;char&nbsp;*[]&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 0, 255, 1)">int</span>&nbsp;*nrow,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">结果集中行的数目&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 0, 255, 1)">int</span>&nbsp;*ncolumn,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">结果集中字段的数目&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 0, 255, 1)">char</span>&nbsp;**errmsg&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">错误信息&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span><br>
)&nbsp;</div>
<div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./SQLite3 API总结_files/copycode.gif" alt="复制代码"></a></span></div></div>
<p>&nbsp;</p>
<h2 style="text-align: justify">3.3 准备查询 <button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h2>
<h3 style="text-align: justify">3.3.1 编译 <button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h3>
<p>&nbsp;&nbsp;&nbsp;&nbsp; 编译或准备接收SQL语句，并将其编译为虚拟数据库引擎（VDBE）可读的字节码。这是由函数sqlite3_prepare_v2()完成的，其声明如下： </p>
<div class="cnblogs_code"><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./SQLite3 API总结_files/copycode.gif" alt="复制代码"></a></span></div>
<div><span style="color: rgba(0, 0, 255, 1)">int</span>&nbsp;sqlite3_prepare_v2(&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;sqlite3&nbsp;*db,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">数据库句柄&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 0, 255, 1)">const</span>&nbsp;<span style="color: rgba(0, 0, 255, 1)">char</span>&nbsp;*zSql,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">SQL文本&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 0, 255, 1)">int</span>&nbsp;nBytes,&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;ssqlite3_stmt&nbsp;**ppStmt,&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 0, 255, 1)">const</span>&nbsp;<span style="color: rgba(0, 0, 255, 1)">char</span>&nbsp;**pzTail&nbsp;<br>
)&nbsp;</div>
<div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./SQLite3 API总结_files/copycode.gif" alt="复制代码"></a></span></div></div>
<p>&nbsp;</p>
<h3 style="text-align: justify">3.3.2 执行 <button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h3>
<p>&nbsp;&nbsp;&nbsp; 一旦查询语句准备就绪，下一步就是使用sqlite3_step()执行，sqlite3_step()声明如下： </p>
<div class="cnblogs_code">
<div><span style="color: rgba(0, 0, 255, 1)">int</span>&nbsp;sqlite3_step(sqlite3_stmt&nbsp;*pStmt);&nbsp;</div>
</div>
<p style="margin-left: 21pt">&nbsp;对于不返回数据的SQL语句，对sqlite3_step()的第一次调用就执行完SQL语句，并返回一个指示结果的代码。对于返回数据的SQL语句，例如select语句，sqlite3_step()第一次调用将语句定位在第一个记录的B-tree光标上。后续调用的sqlite3_step()将光标定位在结果集内的后续记录。到底末尾值之前，sqlite3_step()为结果集中的每个记录返回SQLITE_ROW。返回SQLITE_DONE，表示游标已到底结果集末尾。 </p>
<h3 style="text-align: justify">3.3.3 完成与重置 <button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h3>
<p style="margin-left: 21pt">一旦语句执行结束，必须终止。可以使用一下之一完成或重置语句： </p>
<div class="cnblogs_code">
<div><span style="color: rgba(0, 0, 255, 1)">int</span>&nbsp;slqite3_finalize(sqlite3_stmt&nbsp;*pStmt);&nbsp;<br>
<span style="color: rgba(0, 0, 255, 1)">int</span>&nbsp;sqlite3_reset(sqlite3_stmt&nbsp;*pStmt);&nbsp;</div>
</div>
<p style="margin-left: 21pt">&nbsp;sqlite3_finalize()将关闭语句。释放资源并提交或回滚任何隐式事务。 </p>
<p style="margin-left: 21pt">如果要重复使用语句，可以使用sqlite3_reset()。该函数将保持已编译的SQL语句（和任何绑定的参数）,但是会将单签语句相关联的变化提交到数据库。如果穷了自动提交，它坏释放锁定并清除日志文件。sqlite3_finalize()和sqlite3_reset()之间的主要差别在于后者保留与语句关联的资源，使它可以重新执行，避免了再次调用sqlite3_prepare()编译SQL命令。 </p>
<h2 style="text-align: justify">3.4 获取记录 <button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h2>
<p style="margin-left: 21pt">对于返回记录的语句而言，可以使用函数sqlite3_column_count()和sqlite3_dta_count()获得结果集中的字段数，这两个函数声明如下：</p>
<div class="cnblogs_code">
<div><span style="color: rgba(0, 0, 255, 1)">int</span>&nbsp;sqlite3_column_count(sqlite3_stmt&nbsp;*pStmt);&nbsp;<br>
<span style="color: rgba(0, 0, 255, 1)">int</span>&nbsp;sqlite3_data_count(sqlite3_stmt&nbsp;*pStmt);&nbsp;</div>
</div>
<p style="margin-left: 21pt">&nbsp;</p>
<h3 style="text-align: justify">3.4.1 获取字段信息 <button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h3>
<p>可以是会用sqlite3_column_name()函数获取当前记录中的所有列。 </p>
<p>同样，可以使用sqlite3_column_type()函数获取每个字段关联的存储类。 </p>
<h3 style="text-align: justify">3.4.2 获取字段值 <button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h3>
<p style="margin-left: 21pt">可以使用sqlite3_column_xxx()函数获取当前记录中的所有字段值，该函数的通用形式如下： </p>
<div class="cnblogs_code">
<div>xxx&nbsp;sqlite3_column_xxx(&nbsp;<br>
sqltie3_stmt&nbsp;*,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">语句句柄&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span><span style="color: rgba(0, 0, 255, 1)">int</span>&nbsp;iCol&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">字段的次序&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span>)&nbsp;</div>
</div>
<p style="margin-left: 21pt">&nbsp;</p>
<h2 style="text-align: justify">3.5 查询参数化 <button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h2>
<p>准备语句后，可以使用sqlite3_bind_xxx()函数绑定参数值。这些函数的一般形式如下： </p>
<div class="cnblogs_code">
<div>sqlite3_bind_xxx(&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;sqlite3_stmt*,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">语句句柄&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 0, 255, 1)">int</span>&nbsp;I,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">参数个数&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span>&nbsp;&nbsp;&nbsp;&nbsp;xxx&nbsp;value&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">绑定的值&nbsp;</span><span style="color: rgba(0, 128, 0, 1)"><br>
</span>)</div>
</div>
<p>&nbsp;</p>
</div>
<div class="clear"></div>
<div id="blog_post_info_block" role="contentinfo">
<div id="EntryTag">
    标签: 
            <a href="https://www.cnblogs.com/huliangwen/tag/C%2B%2B/">C++</a></div>

    <div id="blog_post_info">
<div id="green_channel">
        <a href="javascript:void(0);" id="green_channel_digg" onclick="DiggIt(5005756,cb_blogId,1);green_channel_success(this,&#39;谢谢推荐！&#39;);">好文要顶</a>
        <a id="green_channel_follow" onclick="follow(&#39;796a7ca2-f17f-e211-9984-842b2b196315&#39;);" href="javascript:void(0);">关注我</a>
    <a id="green_channel_favorite" onclick="AddToWz(cb_entryId);return false;" href="javascript:void(0);">收藏该文</a>
    <a id="green_channel_weibo" href="javascript:void(0);" title="分享至新浪微博" onclick="ShareToTsina()"><img src="./SQLite3 API总结_files/icon_weibo_24.png" alt=""></a>
    <a id="green_channel_wechat" href="javascript:void(0);" title="分享至微信" onclick="shareOnWechat()"><img src="./SQLite3 API总结_files/wechat.png" alt=""></a>
</div>
<div id="author_profile">
    <div id="author_profile_info" class="author_profile_info">
            <a href="https://home.cnblogs.com/u/huliangwen/" target="_blank"><img src="./SQLite3 API总结_files/sample_face.gif" class="author_avatar" alt=""></a>
        <div id="author_profile_detail" class="author_profile_info">
            <a href="https://home.cnblogs.com/u/huliangwen/">xiuneng</a><br>
            <a href="https://home.cnblogs.com/u/huliangwen/followers/">粉丝 - <span class="follower-count">46</span></a>
            <a href="https://home.cnblogs.com/u/huliangwen/followees/">关注 - <span class="following-count">0</span></a><br>
        </div>
    </div>
    <div class="clear"></div>
    <div id="author_profile_honor"></div>
    <div id="author_profile_follow" class="follow-tip">
                <a href="javascript:void(0);" onclick="follow(&#39;796a7ca2-f17f-e211-9984-842b2b196315&#39;);return false;">+加关注</a>
    </div>
</div>
<div id="div_digg">
    <div class="diggit" onclick="votePost(5005756,&#39;Digg&#39;)">
        <span class="diggnum" id="digg_count">0</span>
    </div>
    <div class="buryit" onclick="votePost(5005756,&#39;Bury&#39;)">
        <span class="burynum" id="bury_count">0</span>
    </div>
    <div class="clear"></div>
    <div class="diggword" id="digg_tips">
    </div>
</div>

<script type="text/javascript">
    currentDiggType = 0;
</script></div>
    <div class="clear"></div>
    <div id="post_next_prev"></div>
</div>
            </div>
            <div class="postDesc">posted @ 
<span id="post-date">2015-11-29 22:04</span>&nbsp;
<a href="https://www.cnblogs.com/huliangwen/">xiuneng</a>&nbsp;
阅读(<span id="post_view_count">2106</span>)&nbsp;
评论(<span id="post_comment_count">0</span>)&nbsp;
<a href="https://i.cnblogs.com/EditArticles.aspx?postid=5005756" rel="nofollow">编辑</a>&nbsp;
<a href="javascript:void(0)" onclick="AddToWz(5005756);return false;">收藏</a>&nbsp;
<a href="javascript:void(0)" onclick="reportManager.report({ currentUserId: &#39;&#39;, targetType: &#39;blogPost&#39;, targetId: &#39;5005756&#39;, targetLink: &#39;https://www.cnblogs.com/huliangwen/articles/5005756.html&#39;, title: &#39;SQLite3 API总结&#39; })">举报</a></div>
        </div>
	    
	    
    </div><!--end: topics 文章、评论容器-->
</div>

<script>
    var cb_entryId = 5005756, cb_entryCreatedDate = '2015-11-29 22:04', cb_postType = 2, cb_postTitle = 'SQLite3 API总结';
    var allowComments = true, cb_blogId = 173795, cb_blogApp = 'huliangwen', cb_blogUserGuid = '796a7ca2-f17f-e211-9984-842b2b196315';
    mermaidRender.render()
    markdown_highlight()
    zoomManager.apply("#cnblogs_post_body img:not(.code_img_closed):not(.code_img_opened)");
    updatePostStats(
            [cb_entryId],
            function(id, count) { $("#post_view_count").text(count) },
            function(id, count) { $("#post_comment_count").text(count) })
</script>
<a id="!comments"></a>
<div id="blog-comments-placeholder"></div>
<div id="comment_form" class="commentform">
    <a name="commentform"></a>
    <div id="divCommentShow"></div>
    <div id="comment_nav"><span id="span_refresh_tips"></span><a href="javascript:void(0);" onclick="return RefreshCommentList();" id="lnk_RefreshComments" runat="server" clientidmode="Static">刷新评论</a><a href="https://www.cnblogs.com/huliangwen/articles/5005756.html#" onclick="return RefreshPage();">刷新页面</a><a href="https://www.cnblogs.com/huliangwen/articles/5005756.html#top">返回顶部</a></div>
    <div id="comment_form_container" style="visibility: visible;"><div class="login_tips">
    登录后才能查看或发表评论，立即 <a rel="nofollow" href="javascript:void(0);" class="underline" onclick="return account.login(&#39;!comments&#39;);">登录</a> 或者
    <a href="https://www.cnblogs.com/">逛逛</a> 博客园首页
</div>
</div>
    <div class="ad_text_commentbox" id="ad_text_under_commentbox"></div>
        <div id="cnblogs_ch"><a href="https://curl.qcloud.com/k19RDMHo" target="_blank" onclick="gtag(&#39;event&#39;, &#39;click&#39;, {&#39;event_category&#39;: &#39;ad&#39;, &#39;event_label&#39;: &#39;T2-腾讯云&#39;})">【推荐】腾讯云多款云产品1折起，买云服务器送免费机器</a><br></div>
    <div id="opt_under_post"></div>
    <div id="cnblogs_c1" class="under-post-card" style="display: none;">
            <div id="div-gpt-ad-1592365906576-0" style="width: 300px; height: 250px;"></div>
    </div>
    <div id="under_post_card1"><div class="under-post-card">
<b>编辑推荐：</b>
<br>

· <a href="https://www.cnblogs.com/InCerry/p/Use-SourceGenerator-Logger.html" target="_blank">.NET性能优化-使用SourceGenerator-Logger记录日志</a>
    <br>
· <a href="https://www.cnblogs.com/AcAc-t/p/linux_watermark_and_kafka_batch_send.html" target="_blank">记一次 Linux server 偶发 CPU 飙升问题的跟进与解决</a>
    <br>
· <a href="https://www.cnblogs.com/huangxincheng/p/16524963.html" target="_blank">记一次 .NET 某智慧物流 WCS 系统 CPU 爆高分析</a>
    <br>
· <a href="https://www.cnblogs.com/InCerry/p/how-to-build-dotnet-image-with-trace-tool.html" target="_blank">如何创建一个带诊断工具的 .NET 镜像</a>
    <br>
· <a href="https://www.cnblogs.com/chanmufeng/p/16523365.html" target="_blank">说透缓存一致性与内存屏障</a>
    <br>
</div></div>
    <div id="under_post_card2"><div class="itnews under-post-card">
    <b>最新新闻</b>：
    <br>
 ·          <a href="https://news.cnblogs.com/n/725796/" target="_blank">腾讯股价跌破 300 港元，段永平花费 2934 万港元再度抄底</a>
        <br>
 ·          <a href="https://news.cnblogs.com/n/725795/" target="_blank">小马智行与曹操出行达成合作，推动自动驾驶出租车规模化落地</a>
        <br>
 ·          <a href="https://news.cnblogs.com/n/725794/" target="_blank">苹果用大屏的Max取代小屏mini，然后把iPhone卖得更贵</a>
        <br>
 ·          <a href="https://news.cnblogs.com/n/725793/" target="_blank">Yandex 开源 userver 框架，用于构建高负载应用程序</a>
        <br>
 ·          <a href="https://news.cnblogs.com/n/725792/" target="_blank">名创优品会成为下一个瑞幸吗？</a>
        <br>
    » <a href="https://news.cnblogs.com/" title="IT 新闻" target="_blank">更多新闻...</a>
</div></div>
    <div id="HistoryToday" class="under-post-card" style="display: none;"></div>
    <script type="text/javascript">
        var commentManager = new blogCommentManager();
        commentManager.renderComments(0);
        fixPostBody();

            window.tocManager.displayDisableTocTips = false;
            window.tocManager.generateToc();
            
                setTimeout(function() { countViews(cb_blogId, cb_entryId); }, 50);
            
            deliverT2();
            deliverC1C2();
            loadNewsAndKb();
            
                LoadPostCategoriesTags(cb_blogId, cb_entryId);
            
            LoadPostInfoBlock(cb_blogId, cb_entryId, cb_blogApp, cb_blogUserGuid);
            GetPrevNextPost(cb_entryId, cb_blogId, cb_entryCreatedDate, cb_postType);
            loadOptUnderPost();
            GetHistoryToday(cb_blogId, cb_blogApp, cb_entryCreatedDate);
                </script>
</div>

	</div><!--end: forFlow -->
	</div><!--end: mainContent 主体内容容器-->
	<div id="sideBar">
		<div id="sideBarMain">
			<div id="sidebar_news" class="newsItem"><!--done-->
<h3 class="catListTitle">公告</h3>

<div id="blog-news">
    
    <div id="profile_block">
        昵称：
        <a href="https://home.cnblogs.com/u/huliangwen/">
            xiuneng
        </a>
        <br>
        园龄：
        <a href="https://home.cnblogs.com/u/huliangwen/" title="入园时间：2013-02-26">
            9年5个月
        </a>
        <br>
        粉丝：
        <a class="follower-count" href="https://home.cnblogs.com/u/huliangwen/followers/">
            46
        </a>
        <br>
        关注：
        <a class="folowing-count" href="https://home.cnblogs.com/u/huliangwen/followees/">
            0
        </a>
        <div id="p_b_follow" class="follow-tip">
<a href="javascript:void(0)" onclick="follow(&#39;796a7ca2-f17f-e211-9984-842b2b196315&#39;)">+加关注</a></div>
        <script>getFollowStatus('796a7ca2-f17f-e211-9984-842b2b196315');</script>
    </div>
</div>

</div>
<div id="sidebar_c3"></div>
			<div id="blog-calendar" style="">

<table id="blogCalendar" class="Cal" cellspacing="0" cellpadding="0" title="Calendar" border="0">
    <tbody>
        <tr>
            <td colspan="7">
                <table class="CalTitle" cellspacing="0" border="0">
                    <tbody>
                        <tr>
                            <td class="CalNextPrev">
                                <a href="javascript:void(0);" onclick="loadBlogCalendar(&#39;2022/07/02&#39;); return false;">&lt;</a>
                            </td>
                            <td align="center">2022年8月</td>
                            <td align="right" class="CalNextPrev">
                                <a href="javascript:void(0);" onclick="loadBlogCalendar(&#39;2022/09/02&#39;); return false;">&gt;</a>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </td>
        </tr>
    <tr>
        <th class="CalDayHeader" align="center" abbr="日" scope="col">日</th>
        <th class="CalDayHeader" align="center" abbr="一" scope="col">一</th>
        <th class="CalDayHeader" align="center" abbr="二" scope="col">二</th>
        <th class="CalDayHeader" align="center" abbr="三" scope="col">三</th>
        <th class="CalDayHeader" align="center" abbr="四" scope="col">四</th>
        <th class="CalDayHeader" align="center" abbr="五" scope="col">五</th>
        <th class="CalDayHeader" align="center" abbr="六" scope="col">六</th>
    </tr>
            <tr>
                            <td class="CalOtherMonthDay" align="center">31</td>
                        <td class="" align="center">
                            1
                        </td>
                        <td class="CalTodayDay" align="center">
                            2
                        </td>
                        <td class="" align="center">
                            3
                        </td>
                        <td class="" align="center">
                            4
                        </td>
                        <td class="" align="center">
                            5
                        </td>
                    <td class="CalWeekendDay" align="center">
                        6
                    </td>
            </tr>
                <tr>
                        <td class="CalWeekendDay" align="center">
                            7
                        </td>
                            <td class="" align="center">
                                8
                            </td>
                            <td class="" align="center">
                                9
                            </td>
                            <td class="" align="center">
                                10
                            </td>
                            <td class="" align="center">
                                11
                            </td>
                            <td class="" align="center">
                                12
                            </td>
                        <td class="CalWeekendDay" align="center">
                            13
                        </td>
                </tr>
                <tr>
                        <td class="CalWeekendDay" align="center">
                            14
                        </td>
                            <td class="" align="center">
                                15
                            </td>
                            <td class="" align="center">
                                16
                            </td>
                            <td class="" align="center">
                                17
                            </td>
                            <td class="" align="center">
                                18
                            </td>
                            <td class="" align="center">
                                19
                            </td>
                        <td class="CalWeekendDay" align="center">
                            20
                        </td>
                </tr>
                <tr>
                        <td class="CalWeekendDay" align="center">
                            21
                        </td>
                            <td class="" align="center">
                                22
                            </td>
                            <td class="" align="center">
                                23
                            </td>
                            <td class="" align="center">
                                24
                            </td>
                            <td class="" align="center">
                                25
                            </td>
                            <td class="" align="center">
                                26
                            </td>
                        <td class="CalWeekendDay" align="center">
                            27
                        </td>
                </tr>
                <tr>
                        <td class="CalWeekendDay" align="center">
                            28
                        </td>
                            <td class="" align="center">
                                29
                            </td>
                            <td class="" align="center">
                                30
                            </td>
                            <td class="" align="center">
                                31
                            </td>
                            <td class="CalOtherMonthDay" align="center">
                                1
                            </td>
                            <td class="CalOtherMonthDay" align="center">
                                2
                            </td>
                        <td class="CalOtherMonthDay" align="center">
                            3
                        </td>
                </tr>
                <tr>
                        <td class="CalOtherMonthDay" align="center">
                            4
                        </td>
                            <td class="CalOtherMonthDay" align="center">
                                5
                            </td>
                            <td class="CalOtherMonthDay" align="center">
                                6
                            </td>
                            <td class="CalOtherMonthDay" align="center">
                                7
                            </td>
                            <td class="CalOtherMonthDay" align="center">
                                8
                            </td>
                            <td class="CalOtherMonthDay" align="center">
                                9
                            </td>
                        <td class="CalOtherMonthDay" align="center">
                            10
                        </td>
                </tr>
    </tbody>
</table></div><script>loadBlogDefaultCalendar();</script>			
			<div id="leftcontentcontainer">
				<div id="blog-sidecolumn"><!-- 搜索 -->
<div id="sidebar_search" class="sidebar-block">
    
</div>

<!-- 常用链接 -->
<div id="sidebar_shortcut" class="sidebar-block"><div class="catListLink">
<h3 class="catListTitle">
常用链接
</h3>
<ul>
    <li><a href="https://www.cnblogs.com/huliangwen/p/" title="我的博客的随笔列表">我的随笔</a></li>
<li><a href="https://www.cnblogs.com/huliangwen/MyComments.html" title="我的发表过的评论列表">我的评论</a></li>
<li><a href="https://www.cnblogs.com/huliangwen/OtherPosts.html" title="我评论过的随笔列表">我的参与</a></li>
<li><a href="https://www.cnblogs.com/huliangwen/comments" title="我的博客的评论列表">最新评论</a></li>
<li><a href="https://www.cnblogs.com/huliangwen/tag/" title="我的博客的标签列表">我的标签</a></li>

</ul>
</div>

</div>

<!-- 最新随笔 -->


<!-- 我的标签 -->
<div id="sidebar_toptags" class="sidebar-block"><div class="catListTag">
<h3 class="catListTitle">我的标签</h3>
<ul>
        <li>
            <a href="https://www.cnblogs.com/huliangwen/tag/iOS/">iOS<span class="tag-count">(31)</span></a>
        </li>
        <li>
            <a href="https://www.cnblogs.com/huliangwen/tag/AI/">AI<span class="tag-count">(10)</span></a>
        </li>
        <li>
            <a href="https://www.cnblogs.com/huliangwen/tag/C%2B%2B/">C++<span class="tag-count">(10)</span></a>
        </li>
        <li>
            <a href="https://www.cnblogs.com/huliangwen/tag/CUDA/">CUDA<span class="tag-count">(9)</span></a>
        </li>
        <li>
            <a href="https://www.cnblogs.com/huliangwen/tag/Spark/">Spark<span class="tag-count">(8)</span></a>
        </li>
        <li>
            <a href="https://www.cnblogs.com/huliangwen/tag/Objective-C/">Objective-C<span class="tag-count">(8)</span></a>
        </li>
        <li>
            <a href="https://www.cnblogs.com/huliangwen/tag/TensorFlow/">TensorFlow<span class="tag-count">(6)</span></a>
        </li>
        <li>
            <a href="https://www.cnblogs.com/huliangwen/tag/Linux/">Linux<span class="tag-count">(5)</span></a>
        </li>
        <li>
            <a href="https://www.cnblogs.com/huliangwen/tag/scikit-learn/">scikit-learn<span class="tag-count">(2)</span></a>
        </li>
        <li>
            <a href="https://www.cnblogs.com/huliangwen/tag/Python/">Python<span class="tag-count">(1)</span></a>
        </li>
    

</ul>
</div>

</div>

<!-- 积分与排名 -->


<!-- 随笔分类、随笔档案、文章分类、新闻分类、相册、链接 -->
<div id="sidebar_categories">

    <div id="sidebar_postcategory" class="catListPostCategory sidebar-block">
        <h3 class="catListTitle">
            
    <a class="sidebar-card-title-a" href="https://www.cnblogs.com/huliangwen/categories">随笔分类</a>



        </h3>

        <ul>

                <li data-category-list-item-visible="true" style="display: block">
                    
<a href="https://www.cnblogs.com/huliangwen/category/1067137.html" class="category-item-link" rel="" target="">Artificial Intelligence(5)</a>
 
                </li>                
                <li data-category-list-item-visible="true" style="display: block">
                    
<a href="https://www.cnblogs.com/huliangwen/category/761513.html" class="category-item-link" rel="" target="">C++(6)</a>
 
                </li>                
                <li data-category-list-item-visible="true" style="display: block">
                    
<a href="https://www.cnblogs.com/huliangwen/category/761393.html" class="category-item-link" rel="" target="">CUDA(1)</a>
 
                </li>                
                <li data-category-list-item-visible="true" style="display: block">
                    
<a href="https://www.cnblogs.com/huliangwen/category/761426.html" class="category-item-link" rel="" target="">iOS(39)</a>
 
                </li>                
                <li data-category-list-item-visible="true" style="display: block">
                    
<a href="https://www.cnblogs.com/huliangwen/category/761417.html" class="category-item-link" rel="" target="">Linux(2)</a>
 
                </li>                
                <li data-category-list-item-visible="true" style="display: block">
                    
<a href="https://www.cnblogs.com/huliangwen/category/1067136.html" class="category-item-link" rel="" target="">Spark(8)</a>
 
                </li>                
                <li data-category-list-item-visible="true" style="display: block">
                    
<a href="https://www.cnblogs.com/huliangwen/category/1067135.html" class="category-item-link" rel="" target="">TensorFlow(6)</a>
 
                </li>                
            
        </ul>


    </div>    
</div>

<!-- 最新评论 -->



<!-- 阅读排行榜 -->
<div id="sidebar_topviewedposts" class="sidebar-block"><div class="catListView">
    <h3 class="catListTitle">
        <a href="https://www.cnblogs.com/huliangwen/most-viewed" class="sidebar-card-title-a">
    阅读排行榜
</a>

    </h3>
    <div id="TopViewPostsBlock">
        <ul style="word-break:break-all">
                    <li>
                        <a href="https://www.cnblogs.com/huliangwen/p/5424033.html">
                            1. Linux平台的boost安装全解(9812)
                        </a>
                    </li>
                    <li>
                        <a href="https://www.cnblogs.com/huliangwen/p/7455382.html">
                            2. TensorFlow框架(3)之MNIST机器学习入门(9609)
                        </a>
                    </li>
                    <li>
                        <a href="https://www.cnblogs.com/huliangwen/p/5003657.html">
                            3. CUDA与VS2013安装(9023)
                        </a>
                    </li>
                    <li>
                        <a href="https://www.cnblogs.com/huliangwen/p/7420387.html">
                            4. TF-IDF模型详解(7897)
                        </a>
                    </li>
                    <li>
                        <a href="https://www.cnblogs.com/huliangwen/p/7464673.html">
                            5. TensorFlow框架(5)之机器学习实践(7016)
                        </a>
                    </li>
        </ul>
    </div>
</div></div>

<!-- 评论排行榜 -->


<!-- 推荐排行榜 -->
<div id="sidebar_topdiggedposts" class="sidebar-block">
<div id="topdigg_posts_wrap">
    <div class="catListView">
        <h3 class="catListTitle">
            <a href="https://www.cnblogs.com/huliangwen/most-liked" class="sidebar-card-title-a">推荐排行榜</a>

        </h3>
        <div id="TopDiggPostsBlock">
            <ul style="word-break: break-all">
                        <li>
                            <a href="https://www.cnblogs.com/huliangwen/p/7455382.html">
                                1. TensorFlow框架(3)之MNIST机器学习入门(3)
                            </a>
                        </li>
                        <li>
                            <a href="https://www.cnblogs.com/huliangwen/p/7439653.html">
                                2. TensorFlow框架(1)之Computational Graph详解(3)
                            </a>
                        </li>
                        <li>
                            <a href="https://www.cnblogs.com/huliangwen/p/5468975.html">
                                3. Objective-C：内存管理(3)
                            </a>
                        </li>
                        <li>
                            <a href="https://www.cnblogs.com/huliangwen/p/5444095.html">
                                4. Objective-C：Block(3)
                            </a>
                        </li>
                        <li>
                            <a href="https://www.cnblogs.com/huliangwen/p/7460635.html">
                                5. TensorFlow框架(4)之CNN卷积神经网络详解(2)
                            </a>
                        </li>
            </ul>
        </div>
    </div>
</div></div></div>
                    <script>loadBlogSideColumn();</script>
			</div>			
		</div><!--end: sideBarMain -->
	</div><!--end: sideBar 侧边栏容器 -->
	<div class="clear"></div>
	</div><!--end: main -->
	<div class="clear"></div>
	<div id="footer">
		<!--done-->
Copyright © 2022 xiuneng
<br><span id="poweredby">Powered by .NET 6 on Kubernetes</span>



	</div><!--end: footer -->
</div><!--end: home 自定义的最大容器 -->





<input type="hidden" id="antiforgery_token" value="CfDJ8EOBBtWq0dNFoDS-ZHPSe52liaa3PdZWmGGwb3PmOWB9CSOj2gLc2cRTD_5ghP412SUEe6geYxJLThE0I7u7ahPv1a2Y6U1BzTBerOHBEqEj6Avu-P2KPRAViW6jpj8OdYHrshhBgjT9eJ0a8F0MKv4">
<script async="" src="./SQLite3 API总结_files/js"></script>
<script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
    var kv = getGACustom();
    if (kv) {
        gtag('set', kv);
    }
    gtag('config', 'UA-476124-1');
</script>
<script defer="" src="./SQLite3 API总结_files/hm.js"></script>

</body></html>